﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MuHelper.Tests
{
    [TestClass]
    public class MeasureInitialization
    {
        [TestMethod]
        public void BaseMeasureInitialization()
        {
            var measure = new Measure("m");
            Assert.IsTrue(measure.Base);
            Assert.AreEqual(1, measure.Coefficient);
            Assert.AreEqual("m", measure.Name);
            Assert.IsFalse(measure.IsNone());
            Assert.AreEqual(0, measure.Nodes.Count);
        }

        [TestMethod]
        public void ComplexMeasureInititalization()
        {
            /*
             1 L/h = 0.001m3/h = 3.6
             */
            decimal coefficient = Convert.ToDecimal(0.001/3600); // 0.001/*L in 1 m3*/ / 3600d/*s in 1 h*/
            var measure = new Measure("L/h", coefficient, new Dictionary<string, decimal>{ {"m", 3}, {"s", -1} });
            Assert.AreEqual("L/h", measure.Name);
            Assert.IsFalse(measure.Base);
            Assert.AreEqual(coefficient, measure.Coefficient);
            Assert.IsFalse(measure.IsNone());
            Assert.AreEqual(2, measure.Nodes.Count);

            measure = new Measure("none", 1, new Dictionary<string, decimal>{ {"t", 0}, {"None", 5} });
            Assert.AreEqual(0, measure.Nodes.Count);
        }

        [TestMethod]
        public void InternalMeasureInitialization()
        {
            const decimal coefficient = (decimal) 1.5;
            var measure = new Measure(coefficient, new Dictionary<string, decimal> {{"m", 2}, {"g", 1}});
            
            Assert.AreEqual(string.Empty, measure.Name);
            Assert.IsFalse(measure.Base);
            Assert.AreEqual(coefficient, measure.Coefficient);
            Assert.IsFalse(measure.IsNone());
            Assert.AreEqual(2, measure.Nodes.Count);
        }
    }
}
